package com.cinema;

import java.io.IOException;
import java.util.Calendar;
import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import query.DataQuery;

import com.cinema.data.Adminusr;
import com.cinema.data.PMF;
import com.cinema.data.User;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;


public class AddAdmin extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public AddAdmin(){
		super();
	}
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		doPost(req, resp);
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		int groupid = Integer.parseInt(request.getParameter("groupid"));
		
		Adminusr usr = new Adminusr();
		usr.setUsername(username);
		usr.setPassword(password);
		usr.setGroupid(groupid);
		
		DataQuery query = new DataQuery();
		boolean result = query.addAdminUser(usr);
		if(result)
			response.getWriter().print("1");
		else
			response.getWriter().print("0");
	}
}
